import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex)



export default new Vuex.Store({
    state: {
        shopCart:[],
        coupid:"",
        chosenAddress:{
            id: "",
            name: "",
            tel: "",
            address:"",
            zipCode:"",
            isDefault: true,

        },
        orderDetail:{
            uuid:"",
            status:"",
            goodsList:[]
        },
    },
    getters: {
       getShopCart:state=> state.shopCart,
       getChosenAddress:state=> state.chosenAddress,
       getOrderDetail:state=> state.orderDetail,
    },
    mutations: {
       saveShopCart:(state, shopCart) => state.shopCart = shopCart,
       saveChosenAddress:(state, chosenAddress) => state.chosenAddress = chosenAddress,
        updateData(state,data){
            state.coupid = data
        },
       saveOrderDetail:(state, orderDetail) => state.orderDetail = orderDetail,
    },
    actions: {
       saveShopCartAction: ({commit}, shopCart) => commit("saveShopCart",shopCart),
       saveChosenAddressAction: ({commit}, chosenAddress) => commit("saveChosenAddress",chosenAddress),
       saveOrderDetailAction: ({commit}, orderDetail) => commit("saveOrderDetail",orderDetail),
    },
    modules: {
    }
})